(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

f(X, n__g(X), Y) → f(activate(Y), activate(Y), activate(Y))
g(b) → c
bc
g(X) → n__g(X)
activate(n__g(X)) → g(activate(X))
activate(X) → X

Rewrite Strategy: INNERMOST

(1) NestedDefinedSymbolProof (BOTH BOUNDS(ID, ID) transformation)

The following defined symbols can occur below the 0th argument of f: activate, g
The following defined symbols can occur below the 1th argument of f: activate, g
The following defined symbols can occur below the 2th argument of f: activate, g
The following defined symbols can occur below the 0th argument of activate: activate, g
The following defined symbols can occur below the 0th argument of g: activate, g

Hence, the left-hand sides of the following rules are not basic-reachable and can be removed:
g(b) → c

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

g(X) → n__g(X)
activate(n__g(X)) → g(activate(X))
bc
activate(X) → X
f(X, n__g(X), Y) → f(activate(Y), activate(Y), activate(Y))

Rewrite Strategy: INNERMOST

(3) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(4) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

g(X) → n__g(X) [1]
activate(n__g(X)) → g(activate(X)) [1]
bc [1]
activate(X) → X [1]
f(X, n__g(X), Y) → f(activate(Y), activate(Y), activate(Y)) [1]

Rewrite Strategy: INNERMOST

(5) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(6) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

g(X) → n__g(X) [1]
activate(n__g(X)) → g(activate(X)) [1]
bc [1]
activate(X) → X [1]
f(X, n__g(X), Y) → f(activate(Y), activate(Y), activate(Y)) [1]

The TRS has the following type information:
g :: n__g → n__g
n__g :: n__g → n__g
activate :: n__g → n__g
b :: c
c :: c
f :: n__g → n__g → n__g → f

Rewrite Strategy: INNERMOST

(7) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

f(v0, v1, v2) → null_f [0]

And the following fresh constants:

null_f, const

(8) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

g(X) → n__g(X) [1]
activate(n__g(X)) → g(activate(X)) [1]
bc [1]
activate(X) → X [1]
f(X, n__g(X), Y) → f(activate(Y), activate(Y), activate(Y)) [1]
f(v0, v1, v2) → null_f [0]

The TRS has the following type information:
g :: n__g → n__g
n__g :: n__g → n__g
activate :: n__g → n__g
b :: c
c :: c
f :: n__g → n__g → n__g → null_f
null_f :: null_f
const :: n__g

Rewrite Strategy: INNERMOST

(9) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

c => 0
null_f => 0
const => 0

(10) Obligation:

Complexity RNTS consisting of the following rules:

activate(z) -{ 1 }→ X :|: X >= 0, z = X
activate(z) -{ 1 }→ g(activate(X)) :|: z = 1 + X, X >= 0
b -{ 1 }→ 0 :|:
f(z, z', z'') -{ 1 }→ f(activate(Y), activate(Y), activate(Y)) :|: Y >= 0, z'' = Y, z' = 1 + X, X >= 0, z = X
f(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
g(z) -{ 1 }→ 1 + X :|: X >= 0, z = X

Only complete derivations are relevant for the runtime complexity.

(11) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1, V2),0,[g(V, Out)],[V >= 0]).
eq(start(V, V1, V2),0,[activate(V, Out)],[V >= 0]).
eq(start(V, V1, V2),0,[b(Out)],[]).
eq(start(V, V1, V2),0,[f(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(g(V, Out),1,[],[Out = 1 + X1,X1 >= 0,V = X1]).
eq(activate(V, Out),1,[activate(X2, Ret0),g(Ret0, Ret)],[Out = Ret,V = 1 + X2,X2 >= 0]).
eq(b(Out),1,[],[Out = 0]).
eq(activate(V, Out),1,[],[Out = X3,X3 >= 0,V = X3]).
eq(f(V, V1, V2, Out),1,[activate(Y1, Ret01),activate(Y1, Ret1),activate(Y1, Ret2),f(Ret01, Ret1, Ret2, Ret3)],[Out = Ret3,Y1 >= 0,V2 = Y1,V1 = 1 + X4,X4 >= 0,V = X4]).
eq(f(V, V1, V2, Out),0,[],[Out = 0,V3 >= 0,V2 = V4,V5 >= 0,V = V3,V1 = V5,V4 >= 0]).
input_output_vars(g(V,Out),[V],[Out]).
input_output_vars(activate(V,Out),[V],[Out]).
input_output_vars(b(Out),[],[Out]).
input_output_vars(f(V,V1,V2,Out),[V,V1,V2],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. non_recursive : [g/2]
1. recursive [non_tail] : [activate/2]
2. non_recursive : [b/1]
3. recursive : [f/4]
4. non_recursive : [start/3]

#### Obtained direct recursion through partial evaluation
0. SCC is completely evaluated into other SCCs
1. SCC is partially evaluated into activate/2
2. SCC is completely evaluated into other SCCs
3. SCC is partially evaluated into f/4
4. SCC is partially evaluated into start/3

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations activate/2
* CE 6 is refined into CE [9]
* CE 5 is refined into CE [10]


### Cost equations --> "Loop" of activate/2
* CEs [10] --> Loop 6
* CEs [9] --> Loop 7

### Ranking functions of CR activate(V,Out)
* RF of phase [6]: [V]

#### Partial ranking functions of CR activate(V,Out)
* Partial RF of phase [6]:
- RF of loop [6:1]:
V


### Specialization of cost equations f/4
* CE 8 is refined into CE [11]
* CE 7 is refined into CE [12]


### Cost equations --> "Loop" of f/4
* CEs [12] --> Loop 8
* CEs [11] --> Loop 9

### Ranking functions of CR f(V,V1,V2,Out)

#### Partial ranking functions of CR f(V,V1,V2,Out)


### Specialization of cost equations start/3
* CE 2 is refined into CE [13]
* CE 3 is refined into CE [14]
* CE 4 is refined into CE [15]


### Cost equations --> "Loop" of start/3
* CEs [13,14,15] --> Loop 10

### Ranking functions of CR start(V,V1,V2)

#### Partial ranking functions of CR start(V,V1,V2)


Computing Bounds
=====================================

#### Cost of chains of activate(V,Out):
* Chain [[6],7]: 2*it(6)+1
Such that:it(6) =< Out

with precondition: [V=Out,V>=1]

* Chain [7]: 1
with precondition: [V=Out,V>=0]


#### Cost of chains of f(V,V1,V2,Out):
* Chain [9]: 0
with precondition: [Out=0,V>=0,V1>=0,V2>=0]

* Chain [8,9]: 6*s(2)+4
Such that:aux(1) =< V2
s(2) =< aux(1)

with precondition: [Out=0,V1=V+1,V1>=1,V2>=0]


#### Cost of chains of start(V,V1,V2):
* Chain [10]: 2*s(7)+6*s(9)+4
Such that:s(7) =< V
s(8) =< V2
s(9) =< s(8)

with precondition: []


Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [10] with precondition: []
- Upper bound: nat(V)*2+4+nat(V2)*6
- Complexity: n

### Maximum cost of start(V,V1,V2): nat(V)*2+4+nat(V2)*6
Asymptotic class: n
* Total analysis performed in 84 ms.

(12) BOUNDS(1, n^1)